home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 10, No. 08 (1989-08)(MindCraft Publishing)(Side A).zip / Nibble Volume 10, No. 08 (1989-08)(MindCraft Publishing)(Side A).po / PFX.S < prev    next >
Text File  |  1996-12-24  |  21KB  |  755 lines

  1.  
  2.  
  3. ********************************
  4. *             PFX              *
  5. *  ProDOS Prefix Manipulator   *
  6. *        by Bill Tudor         *
  7. *     COPYRIGHT (C) 1988       *
  8. *     By MicroSPARC, Inc.      *
  9. *     Concord, MA  01742       *
  10. ********************************
  11. *        Merlin 8/16
  12. *-------------------------------
  13. * PFX ia a BASIC.SYSTEM external command
  14. * handler the adds the PFX command to the
  15. * BASIC interpreter. This command allows
  16. * for quick prefix manipulation without
  17. * typing in any filenames.
  18. *-------------------------------
  19. * Syntax:PFX
  20. * <no parameters>
  21. *-------------------------------
  22. * Machine:Any Apple II/ProDOS
  23. * Version:1.2
  24. * Updated:01-Jun-1988
  25. *===============================
  26.  
  27. * Program Equates
  28.  
  29. PTR       = $06          ;$06,$07
  30. PADDR     = $08          ;holds dest. addr.
  31. PFXPTR    = $1A          ;$1A, $1B
  32. DATPTR    = $1C          ;$1C, $1D
  33. CURRENT   = $FA          ;filename to display
  34. FNCNT     = $FB          ;number of filenames
  35. ENTRY     = $FC          ;current directory entry
  36. ZPTEMP1   = $FD          ;temp stor.
  37. ZPTEMP2   = $FE          ;temp stor.
  38. ZPTEMP3   = $FF          ;temp stor.
  39.  
  40. * Monitor/System Equates:
  41.  
  42. CH        = $24          ;40 column cursor horizontal
  43. OPLEN     = $2F          ;monitor; opcode length
  44. A1L       = $3C          ;monitor; MOVE start
  45. A2L       = $3E          ;monitor; MOVE end
  46. A4L       = $42          ;monitor; MOVE destination
  47. HIMEM     = $73          ;current HIMEM
  48. INBUF     = $200         ;keyboard input buffer
  49. CH2       = $57B         ;cursor horizontal
  50. KEYBD     = $C000        ;the keyboard
  51. STROBE    = $C010        ;reset keyboard strobe
  52. RD80COL   = $C01F        ;read 80/40 display switch
  53. SPKR      = $C030        ;produce speaker click
  54. CHKOPLEN  = $F88E        ;check opcode length (NOT LABLED)
  55. TABV      = $FB5B        ;set vertical cursor position
  56. CLREOP    = $FC42        ;clear from cursor down
  57. CLREOL    = $FC9C        ;clear to end of line
  58. WAIT      = $FCA8        ;monitor wait routine
  59. COUT      = $FDED        ;monitor character out routine
  60. MOVE      = $FE2C        ;monitor MOVE
  61.  
  62. * BI Equates:
  63.  
  64. EXTRNCMD  = $BE06        ;externaml command handlers
  65. ERROUT    = $BE09        ;handle an error
  66. XTRNADDR  = $BE50        ;external command address
  67. XLEN      = $BE52        ;external cmd length-1
  68. XCNUM     = $BE53        ;basic command no. (0=ext)
  69. PBITS     = $BE54        ;parameter bits allowed
  70. FBITS     = $BE56        ;found parameter bits
  71. VPATH1    = $BE6C        ;pathname buffer
  72. GOSYSTEM  = $BE70        ;execute MLI call
  73. OSYSBUF   = $BECE        ;open file buffer
  74. OREFNUM   = $BED0        ;file reference #
  75. RWREFNUM  = $BED6        ;file reference #
  76. RWDATA    = $BED7        ;data buffer
  77. RWCOUNT   = $BED9        ;bytes to read
  78. RWTRANS   = $BEDB        ;bytes transferred
  79. CFREFNUM  = $BEDE        ;reference #
  80. GETBUFR   = $BEF5        ;allocate buffer
  81. SUNITNUM  = $BEC7        ;online unit_number
  82. SBUFADR   = $BEC8        ;online buffer
  83. SMARK     = $BEC8        ;file mark
  84. SREFNUM   = $BEC7        ;file refernece #
  85. MACHID    = $BF98        ;machine ID byte
  86. DEVNUM    = $BF30        ;last device used
  87.  
  88. * ProDOS command numbers:
  89.  
  90. On_line   = $C5
  91. Set_Prefix = $C6
  92. Get_Prefix = $C7
  93. Open      = $C8
  94. Read      = $CA
  95. Write     = $CB
  96. Close     = $CC
  97. Set_Mark  = $CE
  98. Get_Mark  = $CF
  99.  
  100.           ORG $4000      ;by convention for cmds
  101.  
  102. *===============================
  103. * Program Installation:
  104. *===============================
  105.  
  106. INSTALL   LDA #>PEND-PSTART+$100
  107.           JSR GETBUFR    ;buy space from BASIC.SYSTEM
  108.           BCC :1
  109.           JMP ERROUT     ;handle the error
  110. :1        STA PADDR      ;save program new address
  111.           LDA #<STRTMSG
  112.           LDX #>STRTMSG
  113.           JSR PRTSTR     ;print the string out
  114.  
  115. *===============================
  116. * Modify the code:
  117. *===============================
  118.  
  119. MODIFY    LDA PADDR
  120.           STA MOD3+1     ;change manually
  121.           CLC
  122.           ADC #3         ;2-byte opcode fixes
  123.           STA MOD1+1     ;change manually
  124.           STA MOD2+1
  125. *-------------------------------
  126.           LDA #<MODSTART
  127.           STA PTR        ;set program pointer
  128.           LDA #>MODSTART
  129.           STA PTR+1
  130. MODLOOP   LDY #0         ;instruction byte offset
  131.           LDA (PTR),Y    ;get opcode
  132.           JSR CHKOPLEN   ;check opcode length
  133.           LDY OPLEN      ;put length in Y
  134.           CPY #$02       ;2=3 byte instruction
  135.           BNE NOMOD      ;no modification of this one
  136.           LDA (PTR),Y    ;get HOB to fix
  137.           CMP #>MODSTART ;is it below our program
  138.           BLT NOMOD      ;yes/no modification
  139.           CMP #>PEND+$200 ;is it above our program
  140.           BGE NOMOD      ;yes/no modification
  141. FIXIT     SEC
  142.           SBC #>PSTART   ;subtract min. location
  143.           CLC
  144.           ADC PADDR
  145.           STA (PTR),Y    ;save the byte
  146. NOMOD     TYA            ;put #bytes-1 into A
  147.           SEC            ;to add 1 more
  148.           ADC PTR        ;add #bytes-1+1 to PTR LOB
  149.           STA PTR        ;and save
  150.           BCC CHKDNE     ;see if we are done
  151.           INC PTR+1      ;fix HOB
  152. CHKDNE    LDA PTR+1      ;HOB of pointer
  153.           CMP #>MODEND   ;on last page yet
  154.           BLT MODLOOP    ;no, keep going
  155.           LDA PTR        ;LOB of pointer
  156.           CMP #<MODEND   ;are we done
  157.           BLT MODLOOP    ;no, finish last page
  158.  
  159. *===============================
  160. * Hook into BASIC.SYSTEM:
  161. *===============================
  162.  
  163.           LDA EXTRNCMD+1
  164.           STA NXTCMD+1   ;copy cuurent external command
  165.           LDA EXTRNCMD+2 ;to the next command in link
  166.           STA NXTCMD+2
  167.           LDA #0
  168.           STA EXTRNCMD+1 ;put our code address in BASIC's
  169.           LDA PADDR      ;global page
  170.           STA EXTRNCMD+2
  171.  
  172. *===============================
  173. * Move the code:
  174. *===============================
  175.  
  176.           LDA #PSTART    ;start of final code
  177.           STA A1L
  178.           LDA #>PSTART
  179.           STA A1L+1      ;start adr. set
  180.           LDA #PEND      ;end of final code
  181.           STA A2L
  182.           LDA #>PEND
  183.           STA A2L+1      ;end adr. set
  184.           LDA #0         ;LOB of destination
  185.           STA A4L
  186.           LDA PADDR      ;HOB of destination
  187.           STA A4L+1      ;destination set
  188.           LDY #0
  189.           JSR MOVE       ;execute monitor move routine
  190.           RTS            ;return to BASIC
  191. *-------------------------------
  192. STRTMSG   DFB #<EM-STRTMSG ;length
  193.           HEX 8D
  194.           ASC "PFX Command Installed.",8D8D
  195. EM        DFB #0
  196. *-------------------------------
  197.                          ;installation complete
  198.  
  199.           DS \           ;move to next page
  200.  
  201. *===============================
  202. * PFX Command Handler:
  203. *===============================
  204.  
  205. MODSTART  = *            ;start of modification
  206.  
  207. PSTART    CLD
  208.           LDA VPATH1
  209.           STA PTR        ;copy command pointer
  210.           LDA VPATH1+1
  211.           STA PTR+1
  212.           LDY #0
  213. :LP       INY
  214.           LDA (PTR),Y
  215.           CMP CMDTXT-1,Y
  216.           BNE NOTOURS    ;not our command
  217.           CPY #4
  218.           BLT :LP
  219.  
  220. *===============================
  221. * Command is ours/send to be parsed:
  222. *===============================
  223.  
  224. PARSE     DEY
  225.           DEY            ;get to cmd length-1
  226.           STY XLEN       ;and save it
  227.           LDA #0
  228.           STA XCNUM      ;mark as external command
  229.           STA PBITS+1    ;no parms
  230.           STA PBITS
  231.           LDA #<PFXCMD
  232.           STA XTRNADDR   ;tell BI where to return
  233. MOD3      LDA #$00
  234.           STA XTRNADDR+1
  235.           CLC
  236.           RTS            ;return control to BI
  237. *
  238. NOTOURS   SEC            ;flag not our command
  239. NXTCMD    JMP $0000      ;link to next command
  240. CMDTXT    ASC 'PFX',0D   ;our command/note:$0D is a
  241.                          ;'trick' to force no parameters
  242.  
  243. *===============================
  244. * The 'real' PFX cmd:
  245. *===============================
  246.  
  247. PFXCMD    LDA #get_prefix
  248.           JSR GOSYSTEM   ;obtain current prefix
  249.           LDA VPATH1
  250.           STA PFXPTR     ;set prefix pointer
  251.           LDA VPATH1+1
  252.           STA PFXPTR+1
  253. POPLP     JSR POPLEVEL   ;move back a level if nesc.
  254. PFXLP     LDY #0
  255.           LDA (PFXPTR),Y ;get prefix length
  256.           CMP #2
  257.           BGE :1         ;must have a prefix
  258.           JSR GETVOLS    ;get vol. names/set default
  259.           JMP DISPLAY    ;display names
  260. :1        JSR GETSUBS    ;get subdirectory names
  261.           JSR FIXCUR     ;determine default
  262.  
  263. *===============================
  264. * Display Prefix and names:
  265. *===============================
  266.  
  267. DISPLAY   LDA MACHID     ;check machine
  268.           LSR
  269.           LSR            ;check bit 1
  270.           BCC :40        ;40-col only
  271.           BIT RD80COL    ;check display
  272.           BMI :80        ;80-col display
  273. :40       LDA #0
  274.           STA CH
  275.           LDA #22
  276.           BNE :GOV       ;always taken
  277. :80       LDA #0
  278.           STA CH2        ;80-col position
  279.           LDA #23        ;last column
  280. :GOV      JSR TABV       ;position cursor
  281.           LDA #<PFXTXT
  282. MOD1      LDX #>PFXTXT
  283.           JSR PRTSTR     ;print title string
  284.           LDA PFXPTR
  285.           LDX PFXPTR+1
  286.           JSR PRTSTR     ;print current prefix
  287.           JSR CLREOP     ;and clear rest of scrn
  288.  
  289. *-------------------------------
  290. * Display proper filename:
  291. *-------------------------------
  292.  
  293.           JSR SETDATPTR  ;set the data pointer
  294.           LDA DATPTR
  295.           LDX DATPTR+1   ;get pointer &
  296.           JSR PRTSTR     ;print the string
  297.  
  298. *-------------------------------
  299. * Handle keypress:
  300. *-------------------------------
  301.  
  302. NONAMES   STA STROBE     ;clear keyboard
  303. NEWKEY    LDA KEYBD
  304.           BPL NEWKEY     ;wait for keypress
  305.           STA STROBE     ;clear strobe
  306.           CMP #$9B       ;is it esc?
  307.           BNE :NOESC
  308.           CLC            ;flag no error
  309.           RTS            ;and exit on ESC
  310. :NOESC    CMP #"\"       ;backslash
  311.           BEQ BCKSLS
  312.           CMP #"<"       ;or "less than"
  313.           BEQ BCKSLS
  314.           CMP #"/"       ;forward slash
  315.           BEQ FORSLS
  316.           CMP #">"       ;or "greater than"
  317.           BEQ FORSLS
  318.           CMP #$8D       ;return pressed
  319.           BEQ RTN
  320.           CMP #$8B       ;up arrow
  321.           BEQ UP
  322.           CMP #$88       ;left arrow
  323.           BEQ UP
  324.           CMP #$8A       ;down arrow
  325.           BEQ DOWN
  326.           CMP #$95       ;right arrow
  327.           BEQ DOWN
  328.           CMP #$98       ;cntrl-X/clear
  329.           BEQ CNTRLX
  330. BADINP    JSR PROBELL    ;ring the bell
  331.           BEQ NEWKEY     ;always taken
  332.  
  333. *-------------------------------
  334. * Handle Backslash:
  335. *-------------------------------
  336.  
  337. BCKSLS    LDY #0
  338.           LDA (PFXPTR),Y ;get current length
  339.           CMP #2         ;min.
  340.           BLT CLRPFX     ;clear prefix & exit
  341.           JMP POPLP      ;pop level
  342. *-------------------------------
  343. CLRPFX    LDA #8         ;clear prefix & exit
  344.           BIT RD80COL
  345.           BMI :80
  346.           STA CH
  347.           BNE :CNT
  348. :80       STA CH2
  349. :CNT      JSR CLREOP     ;clear the screen
  350.           JMP RTN2
  351.  
  352. *-------------------------------
  353. * Handle Forward Slash:
  354. *-------------------------------
  355.  
  356. FORSLS    JSR ADDNAME    ;add current name to it
  357.           JMP PFXLP
  358.  
  359. *-------------------------------
  360. * Handle Return:
  361. *-------------------------------
  362.  
  363. RTN       JSR ADDNAME    ;add current name
  364. RTN2      LDA #set_prefix
  365.           JSR GOSYSTEM   ;set new prefix
  366.           RTS            ;let BI handle errors
  367.  
  368. *-------------------------------
  369. * Handle UP arrow:
  370. *-------------------------------
  371.  
  372. UP        DEC CURRENT
  373.           BPL TODIS
  374.           LDA FNCNT
  375.           STA CURRENT    ;wrap around feature
  376.           DEC CURRENT
  377. TODIS     JMP DISPLAY    ;always taken
  378.  
  379. *-------------------------------
  380. * Handle Down Arrow:
  381. *-------------------------------
  382.  
  383. DOWN      INC CURRENT
  384.           LDA CURRENT
  385.           CMP FNCNT
  386.           BLT TODIS
  387.           LDA #0
  388.           STA CURRENT    ;force current=0
  389.           BEQ TODIS      ;always taken
  390.  
  391. *-------------------------------
  392. * Handle Cntrl-X (or CLEAR):
  393. *-------------------------------
  394.  
  395. CNTRLX    LDA #0         ;just 'zero' the prefix
  396.           TAY
  397.           STA (PFXPTR),Y ;zero the length
  398.           JMP PFXLP      ;always
  399.  
  400. ********************************
  401. *                              *
  402. *       SUBROUTINES            *
  403. *                              *
  404. ********************************
  405.  
  406. *===============================
  407. * Subroutine FIXCUR:
  408. * -Attempt to set CURRENT
  409. *  to the defualt filename
  410. *===============================
  411.  
  412. FIXCUR    LDA FNCNT
  413.           STA CURRENT
  414. :FCLP1    DEC CURRENT
  415.           BEQ :GOTIT     ;got the default
  416.           JSR SETDATPTR  ;set data pointer
  417.           LDY #0
  418.           LDA (PFXPTR),Y
  419.           TAY            ;move current offset
  420.           LDA #1
  421.           STA ZPTEMP1
  422. :FCLP2    INY
  423.           LDA (PFXPTR),Y
  424.           CMP #'/'
  425.           BEQ :GOTIT
  426.           STY ZPTEMP2
  427.           LDY ZPTEMP1
  428.           CMP (DATPTR),Y
  429.           BNE :FCLP1
  430.           LDY ZPTEMP2
  431.           INC ZPTEMP1
  432.           BNE :FCLP2     ;always taken
  433. :GOTIT    RTS
  434.  
  435. *===============================
  436. * Subroutine ADDNAME:
  437. * - Adds CURRENT filename to the
  438. *   prefix buffer.
  439. *===============================
  440.  
  441. ADDNAME   JSR SETDATPTR  ;set data pointer to cur
  442.           LDY #0
  443.           LDA (DATPTR),Y ;get data length
  444.           TAX            ;counter in X
  445.           LDA (PFXPTR),Y
  446.           STA ZPTEMP1    ;offset to PFX
  447.           CLC
  448.           ADC (DATPTR),Y ;add 2 lengths
  449.           STA (PFXPTR),Y ;and save it
  450.           LDY #0
  451.           STY ZPTEMP2    ;offset to DATA
  452. :2        INC ZPTEMP2
  453.           LDY ZPTEMP2
  454.           LDA (DATPTR),Y ;get data
  455.           INC ZPTEMP1
  456.           LDY ZPTEMP1
  457.           STA (PFXPTR),Y ;and move it
  458.           DEX
  459.           BNE :2
  460.  
  461. * Add slash, if nescessary:
  462.  
  463.           LDY #0
  464.           LDA (PFXPTR),Y
  465.           TAY
  466.           LDA (PFXPTR),Y
  467.           CMP #'/'       ;already there
  468.           BEQ :OK
  469.           INY
  470.           LDA #'/'
  471.           STA (PFXPTR),Y ;add the slash
  472.           TYA
  473.           LDY #0
  474.           STA (PFXPTR),Y ;and fix length
  475. :OK       RTS
  476.  
  477. *===============================
  478. * Subroutine SETDATPTR:
  479. * - Sets a pointer to data position
  480. *   of CURRENT filename.
  481. *===============================
  482.  
  483. SETDATPTR LDA CURRENT    ;get current filename
  484. SETDATPTR2 STA ZPTEMP1
  485.           LDA #<MYBUF
  486.           STA DATPTR
  487. MOD2      LDA #>MYBUF
  488.           STA DATPTR+1
  489.           LDA ZPTEMP1
  490.           BEQ :3
  491. :2        LDA #16
  492.           CLC
  493.           ADC DATPTR
  494.           STA DATPTR
  495.           BCC :1
  496.           INC DATPTR+1
  497. :1        DEC ZPTEMP1
  498.           BNE :2
  499. :3        RTS
  500.  
  501. *===============================
  502. * Subroutine GETSUBS:
  503. * - Reads 'DIR' filenames from
  504. *   current prefix directory.
  505. *===============================
  506.  
  507. GETSUBS   LDA FNCNT
  508.           STA ZPTEMP3    ;save old names
  509.           LDY #0
  510.           STY FNCNT      ;zero the count
  511.  
  512. *-------------------------------
  513. * > Open the PFX file:
  514. *-------------------------------
  515.  
  516. SEARCH    LDA HIMEM
  517.           STA OSYSBUF
  518.           LDA HIMEM+1    ;use general-purpose buffer
  519.           STA OSYSBUF+1  ;for our I/O buffer
  520.           LDA #<INBUF
  521.           STA RWDATA     ;use input buffer for data
  522.           LDA #>INBUF
  523.           STA RWDATA+1
  524.           LDA #0
  525.           STA RWCOUNT+1
  526.           STA SMARK+1
  527.           STA SMARK+2
  528.           LDA #$27
  529.           STA RWCOUNT    ;entry_length = $27
  530.           CLC
  531.           ADC #4
  532.           STA SMARK      ;set inital mark past header
  533.           LDA #$0C       ;1 already done
  534.           STA ENTRY      ;current entry
  535.           LDA #open
  536.           JSR GOSYSTEM   ;open the file
  537.           BCS CHKERR     ;handle error
  538.           LDA OREFNUM
  539.           STA CFREFNUM   ;copy reference number
  540.           STA RWREFNUM
  541.           STA SREFNUM
  542.           LDA #Set_Mark  ;must set_mark past dir
  543.           JSR GOSYSTEM   ;header & bytes
  544.           BCS CHKERR
  545.  
  546. *-------------------------------
  547. * > Check where we are in file:
  548. *-------------------------------
  549.  
  550. CHKETRY   LDA ENTRY
  551.           BNE RDENTRY
  552.           LDA #$0D       ;entries_per_block
  553.           STA ENTRY
  554. ADD4      LDA #Get_Mark
  555.           JSR GOSYSTEM
  556.           BCS CHKERR
  557.           LDA SMARK
  558.           CLC
  559.           ADC #5
  560.           STA SMARK      ;save new LOB
  561.           BCC :HOBOK
  562.           INC SMARK+1    ;fix MOB
  563. :HOBOK    LDA #Set_Mark
  564.           JSR GOSYSTEM   ;move over 5 bytes
  565.           BCS CHKERR
  566. *
  567. RDENTRY   LDA #read      ;read an entry
  568.           JSR GOSYSTEM
  569.           BCS CHKERR
  570.           DEC ENTRY
  571.           LDA INBUF      ;stor type/name len
  572.           AND #$F0
  573.           CMP #$D0       ;check for sub
  574.           BNE CHKETRY    ;go to next one
  575.           LDA INBUF
  576.           AND #$0F       ;isolate length
  577.           STA INBUF      ;and save
  578.           TAX
  579.           LDA FNCNT      ;get current count
  580.           JSR SETDATPTR2
  581.           LDY #0
  582. :LP       LDA INBUF,Y
  583.           STA (DATPTR),Y
  584.           INY
  585.           DEX
  586.           BPL :LP
  587.           INC FNCNT      ;increment file cnt
  588.           LDA FNCNT
  589.           CMP #32        ;32 files yet?
  590.           BLT CHKETRY    ;next one
  591.  
  592. *-------------------------------
  593. * > Close the file:
  594. *-------------------------------
  595.  
  596. CLSE      LDA #close     ;close file
  597.           JSR GOSYSTEM
  598.           LDA FNCNT      ;did we find any?
  599.           BNE :1         ;carry should be clear
  600.           JSR PROBELL    ;ring the bell
  601.           LDA ZPTEMP3
  602.           STA FNCNT      ;save old file cnt.
  603.           JSR POPLEVEL   ;pop off a level
  604.           SEC            ;flag keep current
  605. :1        RTS
  606.  
  607. *-------------------------------
  608. * > Check for error:
  609. *-------------------------------
  610.  
  611. CHKERR    CMP #2         ;range error
  612.           BEQ CLSE       ;just close & exit
  613.           CMP #5         ;out of data (/RAM fix)
  614.           BEQ CLSE       ;just close and exit
  615.           PHA            ;save code
  616.           JSR CLSE       ;close file
  617.           PLA
  618.           JMP ERROUT     ;let BI handle it
  619.  
  620. *===============================
  621. * Subroutine GETVOLS:
  622. * - Use ONLINE to obtain volumes
  623. *===============================
  624.  
  625. GETVOLS   LDY #1
  626.           LDA #'/'
  627.           STA (PFXPTR),Y ;add a slash
  628.           TYA
  629.           DEY
  630.           STA (PFXPTR),Y ;1 in count byte
  631. VOLS      LDA #0
  632.           STA SUNITNUM   ;scan all volumes
  633.           STA CURRENT    ;zero is default
  634.           STA FNCNT      ;zero the file count
  635.           LDA DEVNUM     ;last device used
  636.           AND #$F0
  637.           STA ZPTEMP3    ;save for later
  638.           LDA #<INBUF
  639.           LDX #>INBUF
  640.           STA SBUFADR    ;set on_line buf adr
  641.           STA PTR
  642.           STX SBUFADR+1
  643.           STX PTR+1
  644.           LDA #On_line
  645.           JSR GOSYSTEM   ;make on_line call
  646. :VOLLP    LDY #0
  647.           LDA (PTR),Y    ;get name len/sl/dr
  648.           BEQ VRTS       ;display prefix/ect.
  649.           PHA
  650.           AND #$F0
  651.           STA ZPTEMP2
  652.           PLA
  653.           AND #$0F       ;isolate name length
  654.           BEQ :NXTVOL    ;bad volume, go to next
  655.           TAX
  656.           LDA FNCNT
  657.           JSR SETDATPTR2
  658.           INC FNCNT
  659.           TXA
  660.           STA (DATPTR),Y ;save corrected length
  661.           INY
  662. :CLP      LDA (PTR),Y
  663.           STA (DATPTR),Y ;copy over the filename
  664.           INY
  665.           DEX
  666.           BNE :CLP
  667.           LDA ZPTEMP3    ;last device used
  668.           CMP ZPTEMP2    ;is this default device?
  669.           BNE :NXTVOL    ;no, next volume
  670.           LDA FNCNT      ;fix current
  671.           STA CURRENT
  672.           DEC CURRENT
  673. :NXTVOL   LDA #16
  674.           CLC
  675.           ADC PTR
  676.           STA PTR
  677.           BCC :VOLLP
  678.           INC PTR+1
  679.           BNE :VOLLP     ;always taken
  680. VRTS      CLC
  681.           RTS
  682.  
  683. *===============================
  684. * Subroutine POPLEVEL:
  685. *===============================
  686.  
  687. POPLEVEL  LDY #0
  688.           LDA (PFXPTR),Y
  689.           BEQ :2         ;nothing to pop
  690.           TAY
  691. :1        DEY
  692.           BEQ :2         ;trap nothing else to pop
  693.           LDA (PFXPTR),Y
  694.           CMP #'/'       ;next level yet
  695.           BNE :1
  696. :2        TYA
  697.           LDY #0
  698.           STA (PFXPTR),Y ;save new length
  699.           RTS
  700.  
  701. *===============================
  702. * Subroutine PRTSTR:
  703. * Prints string at (A,X).
  704. * Converts to upper-case if II+.
  705. *===============================
  706.  
  707. PRTSTR    STA PTR
  708.           STX PTR+1      ;set pointer
  709.           LDY #0
  710.           LDA (PTR),Y    ;get length
  711.           BEQ :RTS
  712.           TAX            ;length in X
  713. :LP       INY
  714.           LDA (PTR),Y
  715.           ORA #$80       ;set bit 7
  716.           CMP #$E1
  717.           BLT :PRT
  718.           BIT MACHID
  719.           BMI :PRT
  720.           AND #$DF       ;convert to upper if II+
  721. :PRT      JSR COUT
  722.           DEX
  723.           BNE :LP
  724. :RTS      RTS
  725.  
  726. *===============================
  727. * Subroutine PROBELL to produce
  728. * a beep on the speaker. This is
  729. * Apple's ProDOS buzz.
  730. *===============================
  731.  
  732. PROBELL   LDA #$20       ;duration of tone
  733.           STA LENGTH
  734. BELL1     LDA #$2        ;short delay click
  735.           JSR WAIT
  736.           STA SPKR
  737.           LDA #$24       ;long delay click
  738.           JSR WAIT
  739.           STA SPKR
  740.           DEC LENGTH
  741.           BNE BELL1      ;Repeat for LENGTH times
  742.           RTS
  743. LENGTH    DS 1
  744.  
  745. MODEND    = *            ;DO NOT MODIFY TEXT
  746.  
  747. *===============================
  748. * Parameter Lists/Data:
  749. *===============================
  750.  
  751. PFXTXT    STR "Prefix:"
  752. MYBUF     DS 512         ;filename data buffer
  753. *-------------------------------
  754. PEND      = *            ;end of program
  755.